local skel = fk.CreateSkill{
  name = "knu_hanzuo",
  tags = { Skill.Compulsory },
}

local U = require "packages/utility/utility"

Fk:loadTranslationTable{
  ["knu_hanzuo"] = "汉祚",
  [":knu_hanzuo"] = "锁定技，你的体力上限等于体力值+1。",

}

local docheck = function(self, event, target, player, data)
  return target == player and player:hasSkill(skel.name) and (player.maxHp ~= player.hp + 1)
end
local dochange =function(self, event, target, player, data)
  player:broadcastSkillInvoke(skel.name)
  player.room:notifySkillInvoked(player, skel.name)
  player.room:changeMaxHp(player, player.hp - player.maxHp + 1)
end

skel:addEffect(fk.HpChanged, {
  priority = 0.001,
  can_trigger = docheck,
  on_trigger = dochange,
})

skel:addEffect(fk.MaxHpChanged, {
  priority = 0.001,
  can_trigger = docheck,
  on_trigger = dochange,
})

--保险
skel:addEffect(fk.GameStart, {
  priority = 0.001,
  can_trigger = docheck,
  on_trigger = dochange,
})

--双重保险
skel:addEffect(fk.BeforeMaxHpChanged, {
  priority = 0.001,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name)
  end,
  on_trigger = function (self, event, target, player, data)
    if player.maxHp == player.hp + 1 then
      data.prevented = true
    else
      data.num = player.hp - player.maxHp + 1
    end
  end,
})

return skel